package com.pajk.user.api.http;

import java.util.Map;

import org.testng.Assert;
import org.testng.annotations.Test;

import com.pajk.test.api.BaseTest;
import com.pajk.test.client.ContextHelper;
import com.pajk.test.dataprovider.ExcelDataProvider;
import com.pingan.jk.api.request.ApiCode;
import com.pingan.jk.api.request.User_RequestSmsPassoword;
import com.pingan.jk.api.resp.Api_USER_UpstreamSmsInfo;
import com.pingan.jk.client.ApiContext;
import com.pingan.jk.client.BaseRequest;

public class User_RequestSmsPassowordIT extends BaseTest {
	
	@Test(description="user.requestSmsPassoword 发送动态验证密码  SecurityType.RegisteredDevice")
	public void requestSmsPassowordTest(){
		ApiContext context = super.registerDevice();
		
		String mobile = "13819453412";
        User_RequestSmsPassoword req2 = new User_RequestSmsPassoword(mobile,"REGISTER");
        ContextHelper.sendRequest(context, new BaseRequest[] { req2 });
        Assert.assertEquals(req2.getReturnCode() , ApiCode.SUCCESS);
        Api_USER_UpstreamSmsInfo res = req2.getResponse();
		Assert.assertNotNull(res);
		System.out.println(res.upstreamSmsPhoneNumber);//13819453412
		Assert.assertEquals(res.upstreamSmsPhoneNumber, mobile);
		System.out.println(res.smsContent);//U154482
		
        //其他验证方式?
	}
	
	@Test(description="user.requestSmsPassoword 不规范手机号码验证",
			dataProvider = "excel", dataProviderClass = ExcelDataProvider.class)
	public void TestNotSupportMobile(Map<String,String> datadriven){
		ApiContext context = super.registerDevice();
		
        //2.mobile owner requestSmsPassword
		String mobile = datadriven.get("mobile");
        User_RequestSmsPassoword req2 = new User_RequestSmsPassoword(mobile,"REGISTER");
        ContextHelper.sendRequest(context, new BaseRequest[] { req2 });
        Assert.assertEquals(ApiCode.DEVICE_PHONE_NUM_ERROR_1003050, req2.getReturnCode());
        //要获取最新client代码了！！！！！！！！！！！！！！--再debug
        
        Api_USER_UpstreamSmsInfo res = req2.getResponse();
		Assert.assertNotNull(res);
		System.out.println(res.upstreamSmsPhoneNumber);
		System.out.println(res.smsContent);
		
        //tair中记录已发送记录的验证
        
	}
}
